import unittest
from HTMLTestRunner import HTMLTestRunner
import time
import os

if __name__ == '__main__':
    report_dir = os.path.abspath('.')+'/test_report/'
    test_dir = os.path.abspath('.')+'/testsuites'
    discover = unittest.defaultTestLoader.discover(test_dir,pattern='test*.py')
    now = time.strftime("%Y%m%d_%H%M")
    report_name = report_dir + now + "report.html"

    with open(report_name,'wb') as f:
        runner = HTMLTestRunner(stream=f,title='Tester Report',description='执行情况',)
        runner.run(discover)